using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Attributes;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Attributes.DomainAttributes;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Enums;
using System.Collections.Generic;
using System.ComponentModel;

namespace Baci.ArcGIS._SpatialStatisticsTools._Utilities
{
    /// <summary>
    /// <para>Time Series Smoothing</para>
    /// <para>Smooths a numeric variable of one or more time series using centered, forward, and backward moving averages, as well as an adaptive method based on
    /// local linear regression. After smoothing short-term
    /// fluctuations, longer-term trends or cycles often become apparent.</para>
    /// <para>使用居中、正向和向后移动平均线以及基于
    /// 局部线性回归。短期平滑后
    /// 波动、长期趋势或周期往往会变得明显。</para>
    /// </summary>    
    [DisplayName("Time Series Smoothing")]
    public class TimeSeriesSmoothing : AbstractGPProcess
    {
        /// <summary>
        /// 无参构造
        /// </summary>
        public TimeSeriesSmoothing()
        {

        }

        /// <summary>
        /// 有参构造
        /// </summary>
        /// <param name="_in_features">
        /// <para>Input Features or Table</para>
        /// <para>The features or table containing the time series data and the field to smooth.</para>
        /// <para>包含要平滑的时间序列数据和字段的要素或表。</para>
        /// </param>
        /// <param name="_time_field">
        /// <para>Time Field</para>
        /// <para>The field containing the time of each record.</para>
        /// <para>包含每条记录的时间的字段。</para>
        /// </param>
        /// <param name="_analysis_field">
        /// <para>Analysis Field</para>
        /// <para>The field containing the values that will be smoothed.</para>
        /// <para>包含将平滑处理的值的字段。</para>
        /// </param>
        public TimeSeriesSmoothing(object _in_features, object _time_field, object _analysis_field)
        {
            this._in_features = _in_features;
            this._time_field = _time_field;
            this._analysis_field = _analysis_field;
        }
        public override string ToolboxName => "Spatial Statistics Tools";

        public override string ToolName => "Time Series Smoothing";

        public override string CallName => "stats.TimeSeriesSmoothing";

        public override List<string> AcceptEnvironments => ["outputCoordinateSystem"];

        public override object[] ParameterInfo => [_in_features, _time_field, _analysis_field, _group_method.GetGPValue(), _method.GetGPValue(), _time_window, _append_to_input.GetGPValue(), _output_features, _id_field, _apply_shorter_window.GetGPValue(), _enable_time_series_popups.GetGPValue(), _updated_features];

        /// <summary>
        /// <para>Input Features or Table</para>
        /// <para>The features or table containing the time series data and the field to smooth.</para>
        /// <para>包含要平滑的时间序列数据和字段的要素或表。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Input Features or Table")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _in_features { get; set; }


        /// <summary>
        /// <para>Time Field</para>
        /// <para>The field containing the time of each record.</para>
        /// <para>包含每条记录的时间的字段。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Time Field")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _time_field { get; set; }


        /// <summary>
        /// <para>Analysis Field</para>
        /// <para>The field containing the values that will be smoothed.</para>
        /// <para>包含将平滑处理的值的字段。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Analysis Field")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _analysis_field { get; set; }


        /// <summary>
        /// <para>Grouping Method</para>
        /// <para><xdoc>
        ///   <para>Specifies the method that will be used to group records into different time series. Smoothing is performed independently for each time series.</para>
        ///   <bulletList>
        ///     <bullet_item>By location—Features at the same location will be grouped in the same time series. This is the default.</bullet_item><para/>
        ///     <bullet_item>By ID field—Records with the same value of the ID field will be grouped in the same time series.</bullet_item><para/>
        ///     <bullet_item>None—All records will be in the same time series.</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指定将用于将记录分组到不同时间序列中的方法。每个时间序列的平滑处理都是独立执行的。</para>
        ///   <bulletList>
        ///     <bullet_item>按位置 - 同一位置的要素将按同一时间序列进行分组。这是默认设置。</bullet_item><para/>
        ///     <bullet_item>按 ID 字段 - 具有相同 ID 字段值的记录将分组到相同的时间序列中。</bullet_item><para/>
        ///     <bullet_item>无—所有记录将采用相同的时间序列。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Grouping Method")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public _group_method_value _group_method { get; set; } = _group_method_value._LOCATION;

        public enum _group_method_value
        {
            /// <summary>
            /// <para>By location</para>
            /// <para>By location—Features at the same location will be grouped in the same time series. This is the default.</para>
            /// <para>按位置 - 同一位置的要素将按同一时间序列进行分组。这是默认设置。</para>
            /// </summary>
            [Description("By location")]
            [GPEnumValue("LOCATION")]
            _LOCATION,

            /// <summary>
            /// <para>By ID field</para>
            /// <para>By ID field—Records with the same value of the ID field will be grouped in the same time series.</para>
            /// <para>按 ID 字段 - 具有相同 ID 字段值的记录将分组到相同的时间序列中。</para>
            /// </summary>
            [Description("By ID field")]
            [GPEnumValue("ID_FIELD")]
            _ID_FIELD,

            /// <summary>
            /// <para>None</para>
            /// <para>None—All records will be in the same time series.</para>
            /// <para>无—所有记录将采用相同的时间序列。</para>
            /// </summary>
            [Description("None")]
            [GPEnumValue("NONE")]
            _NONE,

        }

        /// <summary>
        /// <para>Smoothing Method</para>
        /// <para><xdoc>
        ///   <para>Specifies the smoothing method that will be used.</para>
        ///   <bulletList>
        ///     <bullet_item>Backward moving average—The smoothed value is the average of the record and the values within the time window before it. This is the default.</bullet_item><para/>
        ///     <bullet_item>Centered moving average—The smoothed value is the average of the record and the values before and after it. Half of the time window is used before the time of the record, and half is used after.</bullet_item><para/>
        ///     <bullet_item>Forward moving average—The smoothed value is the average of the record and the values within the time window after it.</bullet_item><para/>
        ///     <bullet_item>Adaptive bandwidth local linear regression—The smoothed value is the result of a local linear regression centered at the record. The size of the time window is optimized for each record.</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指定将使用的平滑方法。</para>
        ///   <bulletList>
        ///     <bullet_item>向后移动平均线 - 平滑值是记录的平均值及其之前时间窗内的值。这是默认设置。</bullet_item><para/>
        ///     <bullet_item>居中移动平均线 - 平滑值是记录及其前后值的平均值。一半的时间窗口在记录时间之前使用，一半在记录时间之后使用。</bullet_item><para/>
        ///     <bullet_item>前向移动平均线—平滑值是记录及其之后时间窗内的平均值。</bullet_item><para/>
        ///     <bullet_item>自适应带宽局部线性回归 - 平滑值是以记录为中心的局部线性回归的结果。针对每条记录优化了时间窗口的大小。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Smoothing Method")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public _method_value _method { get; set; } = _method_value._BACKWARD;

        public enum _method_value
        {
            /// <summary>
            /// <para>Backward moving average</para>
            /// <para>Backward moving average—The smoothed value is the average of the record and the values within the time window before it. This is the default.</para>
            /// <para>向后移动平均线 - 平滑值是记录的平均值及其之前时间窗内的值。这是默认设置。</para>
            /// </summary>
            [Description("Backward moving average")]
            [GPEnumValue("BACKWARD")]
            _BACKWARD,

            /// <summary>
            /// <para>Centered moving average</para>
            /// <para>Centered moving average—The smoothed value is the average of the record and the values before and after it. Half of the time window is used before the time of the record, and half is used after.</para>
            /// <para>居中移动平均线 - 平滑值是记录及其前后值的平均值。一半的时间窗口在记录时间之前使用，一半在记录时间之后使用。</para>
            /// </summary>
            [Description("Centered moving average")]
            [GPEnumValue("CENTERED")]
            _CENTERED,

            /// <summary>
            /// <para>Forward moving average</para>
            /// <para>Forward moving average—The smoothed value is the average of the record and the values within the time window after it.</para>
            /// <para>前向移动平均线—平滑值是记录及其之后时间窗内的平均值。</para>
            /// </summary>
            [Description("Forward moving average")]
            [GPEnumValue("FORWARD")]
            _FORWARD,

            /// <summary>
            /// <para>Adaptive bandwidth local linear regression</para>
            /// <para>Adaptive bandwidth local linear regression—The smoothed value is the result of a local linear regression centered at the record. The size of the time window is optimized for each record.</para>
            /// <para>自适应带宽局部线性回归 - 平滑值是以记录为中心的局部线性回归的结果。针对每条记录优化了时间窗口的大小。</para>
            /// </summary>
            [Description("Adaptive bandwidth local linear regression")]
            [GPEnumValue("ADAPTIVE")]
            _ADAPTIVE,

        }

        /// <summary>
        /// <para>Time Window</para>
        /// <para>The length of the time window. The value can be provided in seconds, minutes, hours, days, weeks, months, or years. For backward, forward, and centered moving averages, the value and unit must be provided. For adaptive bandwidth local linear regression, the value can be left empty and a time window will be estimated independently for each value. Values that fall on the border of the time window are included within the window. For example, if you have daily data and you use a backward moving average with a time window of four days, five values will be included in the window when smoothing a record: the value of the record and the values of the four previous days.</para>
        /// <para>时间窗口的长度。该值可以以秒、分钟、小时、天、周、月或年为单位提供。对于后向、正向和居中的移动平均线，必须提供值和单位。对于自适应带宽局部线性回归，该值可以留空，并且将独立估计每个值的时间窗口。落在时间窗口边界上的值将包含在窗口中。例如，如果您有每日数据，并且使用时间窗口为 4 天的向后移动平均线，则在平滑记录时，窗口中将包含五个值：记录的值和前四天的值。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Time Window")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _time_window { get; set; } = null;


        /// <summary>
        /// <para>Append fields to input data</para>
        /// <para><xdoc>
        ///   <para>Specifies whether output fields will be appended to the input dataset or saved as a new output table or feature class. If you choose to append the fields to the input, the output coordinate system environment will be ignored.
        ///   <bulletList>
        ///     <bullet_item>Checked—The output fields will be appended to the input features. This option modifies the input data.  </bullet_item><para/>
        ///     <bullet_item>Unchecked—The output fields will not be appended to the input. An output table or a feature class will be created containing the output fields. This is the default.  </bullet_item><para/>
        ///   </bulletList>
        ///   </para>
        /// </xdoc></para>
        /// <para><xdoc>
        /// <para>指定是将输出字段追加到输入数据集中还是另存为新的输出表或要素类。如果选择将字段追加到输入，则输出坐标系环境将被忽略。
        ///   <bulletList>
        ///     <bullet_item>选中 - 输出字段将追加到输入要素中。此选项修改输入数据。 </bullet_item><para/>
        ///     <bullet_item>未选中 - 输出字段不会追加到输入中。将创建包含输出字段的输出表或要素类。这是默认设置。 </bullet_item><para/>
        ///   </bulletList>
        ///   </para>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Append fields to input data")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public _append_to_input_value _append_to_input { get; set; } = _append_to_input_value._false;

        public enum _append_to_input_value
        {
            /// <summary>
            /// <para>APPEND_TO_INPUT</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("APPEND_TO_INPUT")]
            [GPEnumValue("true")]
            _true,

            /// <summary>
            /// <para>NEW_OUTPUT</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("NEW_OUTPUT")]
            [GPEnumValue("false")]
            _false,

        }

        /// <summary>
        /// <para>Output Features</para>
        /// <para>The output features containing the smoothed values as well as fields for the time window and number of neighbors.</para>
        /// <para>包含平滑值的输出要素以及时间窗口和邻居数的字段。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Output Features")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _output_features { get; set; } = null;


        /// <summary>
        /// <para>ID Field</para>
        /// <para>The integer or text field containing a unique ID for each time series. All records with the same value of this field are part of the same time series.</para>
        /// <para>包含每个时间序列的唯一 ID 的整数或文本字段。此字段具有相同值的所有记录都属于同一时间序列。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("ID Field")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _id_field { get; set; } = null;


        /// <summary>
        /// <para>Apply shorter time window at start and end</para>
        /// <para><xdoc>
        ///   <para>Specifies whether the time window will be shortened at the start and end of each time series.
        ///   <bulletList>
        ///     <bullet_item>Checked—The time window will be shortened at the start and end of the time series so that the time window does not extend before the start or after the end of the time series.  </bullet_item><para/>
        ///     <bullet_item>Unchecked—The time window will not be shortened. If the time window extends before the start or after the end of the time series, the smoothed value will be null. This is the default.  </bullet_item><para/>
        ///   </bulletList>
        ///   </para>
        /// </xdoc></para>
        /// <para><xdoc>
        /// <para>指定是否在每个时间序列的开始和结束时缩短时间窗口。
        ///   <bulletList>
        ///     <bullet_item>选中—时间窗口将在时间序列的开始和结束时缩短，以便时间窗口不会在时间序列开始之前或结束之后扩展。</bullet_item><para/>
        ///     <bullet_item>未选中 - 不会缩短时间窗口。如果时间窗口在时间序列开始之前或结束之后延伸，则平滑后的值将为 null。这是默认设置。 </bullet_item><para/>
        ///   </bulletList>
        ///   </para>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Apply shorter time window at start and end")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public _apply_shorter_window_value _apply_shorter_window { get; set; } = _apply_shorter_window_value._false;

        public enum _apply_shorter_window_value
        {
            /// <summary>
            /// <para>APPLY_SHORTER_WINDOW</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("APPLY_SHORTER_WINDOW")]
            [GPEnumValue("true")]
            _true,

            /// <summary>
            /// <para>NOT_APPLY_SHORTER_WINDOW</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("NOT_APPLY_SHORTER_WINDOW")]
            [GPEnumValue("false")]
            _false,

        }

        /// <summary>
        /// <para>Enable time series pop-ups</para>
        /// <para><xdoc>
        ///   <para>Specifies whether the output features or table will include pop-up charts showing the original and smoothed values of the time series.
        ///   <bulletList>
        ///     <bullet_item>Checked—The output will include pop-up charts. This is the default.  </bullet_item><para/>
        ///     <bullet_item>Unchecked—The output will not include pop-up charts.  </bullet_item><para/>
        ///   </bulletList>
        ///   </para>
        /// </xdoc></para>
        /// <para><xdoc>
        /// <para>指定输出要素或表是否包括显示时间序列的原始值和平滑值的弹出图表。
        ///   <bulletList>
        ///     <bullet_item>选中 - 输出将包括弹出图表。这是默认设置。 </bullet_item><para/>
        ///     <bullet_item>未选中 - 输出将不包括弹出图表。</bullet_item><para/>
        ///   </bulletList>
        ///   </para>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Enable time series pop-ups")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public _enable_time_series_popups_value _enable_time_series_popups { get; set; } = _enable_time_series_popups_value._true;

        public enum _enable_time_series_popups_value
        {
            /// <summary>
            /// <para>CREATE_POPUP</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("CREATE_POPUP")]
            [GPEnumValue("true")]
            _true,

            /// <summary>
            /// <para>NO_POPUP</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("NO_POPUP")]
            [GPEnumValue("false")]
            _false,

        }

        /// <summary>
        /// <para>Updated Features or Table</para>
        /// <para></para>
        /// <para></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Updated Features or Table")]
        [Description("")]
        [Option(OptionTypeEnum.derived)]
        public object _updated_features { get; set; }


        public TimeSeriesSmoothing SetEnv(object outputCoordinateSystem = null)
        {
            base.SetEnv(outputCoordinateSystem: outputCoordinateSystem);
            return this;
        }

    }

}